
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Tables"
clear
log using Table4.txt, text replace

***Complier characterization

**Panel A: Frequency of Complier
clear all
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Tables"

**Probability of Completing an IPO
keep id ipo pos_returns lag30
duplicates drop
sum ipo pos_returns
**Prob D(=1) =87.59%
**Prob Z=1=61.8%

**Prob of (Complier/Completed IPO)=(FS-coef)*P(Z=1)/P(D=1)=6.9%*61.8%/87.59%=4.87%
**Prob of (Complier/Failed IPO)=(FS-coef)*P(Z=0)/P(D=0)=6.9%*(1-61.8%)/(1-87.59%)=21.22%

**Panel B: Characteristics of Compliers
clear all
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Tables"

eststo clear 

***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 


****Setting the sample to the IV sample (dropping observations colinear with FEs)
set more off
qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* , fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
gen sample_IV=e(sample) 
keep if sample_IV==1
**Dropping firms for which ROA only has one observation
bysort id: egen count=count(year)
drop if count==1 

***Cross-sectional sample splits
sum hi_wroa hi_assets_MM hi_sales_MM hi_age_w hi_wleverage hi_anti_self

***Main First-stage
qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
scalar Main_FS = _b[instrument]

**High pre-IPO OROA
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_wroa==1, fe cluster(id) 
scalar Hi_OROA_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_OROA = Hi_OROA_FS / Main_FS
display %9.2f ratio_Hi_OROA

**High pre-IPO Assets
eststo clear 
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_assets_MM==1, fe cluster(id) 
scalar Hi_ASS_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_ASS = Hi_ASS_FS / Main_FS
display %9.2f ratio_Hi_ASS

**High pre-IPO Sales
eststo clear 
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_sales_MM==1, fe cluster(id) 
scalar Hi_Sales_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_Sales = Hi_Sales_FS / Main_FS
display %9.2f ratio_Hi_Sales 

**High pre-IPO age
eststo clear 
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_age_w==1, fe cluster(id) 
scalar Hi_Age_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_Age = Hi_Age_FS / Main_FS
display %9.2f ratio_Hi_Age 


**High pre-IPO Leverage
eststo clear 
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_wleverage==1, fe cluster(id) 
scalar Hi_Lev_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_Lev = Hi_Lev_FS / Main_FS
display %9.2f ratio_Hi_Lev 


**High anti-self
eststo clear 
set more off
eststo: qui xtreg IPO instrument deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if hi_anti_self==1, fe cluster(id) 
scalar Hi_ASD_FS = _b[instrument]
**Reporting Coefficients
esttab,   keep(instrument) order(instrument) label b(%9.4f) se noobs replace
***Reporting ratio
scalar ratio_Hi_ASD = Hi_ASD_FS / Main_FS
display %9.2f ratio_Hi_ASD 

cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Tables"
log close
